<template>
	<view class="page_view">
		<!-- 会诊订单 -->
		<view class="zhanwei"></view>
		<view class="list_item" style="margin-bottom: 20rpx;" v-for="(item,index) in consuList" :key="index"
			@click="goDetail(item)">
			<view class="list_item_top">
				<view class="list_item_top1 flex">
					<view class="list_item_top1_left flex1">
						<image :src="ImgUrl+item.doctors[0].doctor.avatar" class="list_item_top1_img" mode=""></image>
						<view class="list_item_top1_left_name">
							{{item.doctors[0].doctor.name}} <text
								class="list_item_top1_left_zhicheng">{{item.doctors[0].doctor.level.name}}</text>
						</view>
						<view class="list_item_top1_left_type">
							{{item.type == 1?'图文':item.type == 2?'视频':item.type == 3?'飞刀':'多人'}}问诊
						</view>
					</view>
					<view class="list_item_top1_left_name">
						{{item.status == 0?'待预约':item.status == 1?'已预约':item.status == 2?'服务中':item.status == 3?'已结束':item.status == 4?'已评价':item.status == 5?'创建订单失败':item.status == 6?'已取消':''}}
					</view>
					<!-- <view class="list_item_top1_left_name jinxingzhong" v-if="index == 1">
						进行中
					</view>
					<view class="list_item_top1_left_name quxiao" v-if="index == 2">
						已取消
					</view> -->
				</view>
				<view class="list_item_top2">
					<view class="list_item_top2_item flex">
						<view class="list_item_top2_item_left">
							科室名称
						</view>
						<view class="list_item_top2_item_right">
							{{item.doctors[0].doctor.hospital.name}}-{{item.doctors[0].doctor.department.name}}
						</view>
					</view>
					<view class="list_item_top2_item flex">
						<view class="list_item_top2_item_left">
							咨询时间
						</view>
						<view class="list_item_top2_item_right">
							{{item.created_at}}
						</view>
					</view>
					<view class="list_item_top2_item flex">
						<view class="list_item_top2_item_left">
							问诊类型
						</view>
						<view class="list_item_top2_item_right">
							{{item.type == 1?'图文':item.type == 2?'视频':item.type == 3?'飞刀':'多人'}}问诊
						</view>
					</view>
					<view class="list_item_top2_item flex">
						<view class="list_item_top2_item_left">
							服务费
						</view>
						<view class="list_item_top2_item_right">
							{{item.actually_amount}}元
						</view>
					</view>
				</view>
			</view>
			<view v-if="item.status == 3||item.status == 4" class="list_item_bottom flex1">
				<view @click="fuzhen(item)" v-if="item.status == 3" class="list_item_bottom_brn btn1">
					复诊
				</view>
				<view v-if="item.status == 3" class="list_item_bottom_brn btn2">
					患者评价
				</view>
				<view v-if="item.status == 4||item.status == 3" class="list_item_bottom_brn btn2"
					@click.stop="delet(item.id)">
					删除
				</view>
			</view>
		</view>
		<view class="" v-if="consuList.length == 0">
			<u-empty text="列表为空" mode="list"></u-empty>
		</view>
	</view>
</template>

<script>
	import {
		consultation,
		consuDel
	} from '../../api/login.js';
	export default {
		data() {
			return {
				consuList: [],
				page: 1,
				last_page: ''
			}
		},
		mounted() {

		},
		onShow() {
			this.getList();
		},
		computed: {
			ImgUrl() {
				console.log(this.$store.state.ImgUrl)
				return this.$store.state.ImgUrl
			},
		},
		// 页面定义
		onReachBottom() {
			if (this.page < parseInt(this.last_page)) {
				this.page++
				this.getList()
			}
		},
		methods: {
			fuzhen(item) {
				// console.log(item.doctors[0].doctor,'cs');
				let type = item.type - 1;
				uni.navigateTo({
					url: '/pages/ReservationInformation/ReservationInformation?type=' + type + '&data=' + JSON
						.stringify(item.doctors[0].doctor)
				})
			},
			goDetail(item) {
				if (item.status == 6) {
					return;
				}
				uni.navigateTo({
					url: '/pages/Consultation/Consultation?id=' + item.id
				})
			},
			delet(id) {
				uni.showModal({
					title: '提示',
					content: '确认删除订单吗?',
					success: res => {
						if (res.confirm) {
							consuDel({
								id: id
							}).then((res) => {
								if (res.code == 200001) {
									uni.showToast({
										title: '删除成功',
										icon: 'none'
									})
									this.getList();
								} else {
									uni.showToast({
										title: res.message,
										icon: 'none'
									})
								}
							})
						}
					}
				})
			},
			getList() {
				let t = this;
				consultation().then((res) => {
					if (res.code == 200001) {
						t.consuList = res.data.data;
						t.last_page = res.data.last_page;
					}
				})
			},
			go_pingjia(data) {
				uni.navigateTo({
					url: '/pages/Evaluate/Evaluate?data=' + JSON.stringify(data)
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #F4F4F4;
	}

	.zhanwei {
		width: 100%;
		height: 12rpx;
	}

	.page_view {
		padding: 0 30rpx;
		box-sizing: border-box;
	}

	.list_item {
		width: 100%;
		padding: 0 30rpx;
		box-sizing: border-box;
		background-color: #fff;
		border-radius: 20rpx;
		margin-top: 8rpx;
	}

	.list_item_top {
		padding: 30rpx 0;
		box-sizing: border-box;
	}

	.list_item_top1_img {
		width: 44rpx;
		height: 44rpx;
		border-radius: 12rpx;
		background-color: #ddd;
		margin-right: 16rpx;
	}

	.list_item_top1_left_type {
		display: inline-flex;
		padding: 4rpx 6rpx;
		border-radius: 4rpx;
		background: #FF9D43;
		color: #FFF;
		text-align: center;
		font-family: Alibaba PuHuiTi 2.0;
		font-size: 20rpx;
		font-weight: 400;
		margin-left: 8rpx;
	}

	.list_item_top1_left_zhicheng {
		color: #444;
		font-family: Alibaba PuHuiTi 2.0;
		font-size: 26rpx;
		font-weight: 400;
		margin-left: 4rpx;
	}

	.list_item_top1_left_name {
		color: #333;
		font-family: Alibaba PuHuiTi 2.0;
		font-size: 32rpx;
		font-weight: 400;
	}

	.jinxingzhong {
		color: #FF9D43;
	}

	.quxiao {
		color: #999;
	}

	.list_item_top2_item:first-child {
		margin-top: 30rpx;
	}

	.list_item_top2_item {
		margin-top: 14rpx;
	}

	.list_item_top2_item_left {
		color: #333;
		font-family: Alibaba PuHuiTi 2.0;
		font-size: 24rpx;
		font-weight: 400;
	}

	.list_item_top2_item_right {
		color: #999;
		text-align: right;
		font-family: Alibaba PuHuiTi 2.0;
		font-size: 24rpx;
		font-weight: 400;
	}

	.list_item_bottom {
		width: 100%;
		height: 112rpx;
		flex-direction: row-reverse;
		border-top: 1rpx #F4F4F4 solid;
	}

	.list_item_bottom_brn {
		width: 128rpx;
		height: 52rpx;
		border-radius: 50rpx;
		text-align: center;
		line-height: 52rpx;
		font-family: Alibaba PuHuiTi 2.0;
		font-size: 24rpx;
		font-weight: 400;
		margin-left: 30rpx;
	}

	.btn1 {
		background: var(--, linear-gradient(270deg, #0165FB 0%, #7AA7EB 100%));
		color: #fff;
	}

	.btn2 {
		border: 1px solid #CCC;
		color: #666;
	}
</style>